package com.aismy.admin.utils;


import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;

@Component
public class PasswordUtils {

    private static final String SALT = "aismy_mental_health";  // 加盐增加安全性

    /**
     * 加密密码
     */
    public String encrypt(String password) {
        return DigestUtils.md5DigestAsHex((password + SALT).getBytes());
    }

    /**
     * 验证密码
     */
    public boolean verify(String password, String encrypted) {
        return encrypt(password).equals(encrypted);
    }

} 